<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../mixins/style/base.css" />
    <link rel="stylesheet" href="../mixins/style/normalize.css" />



</head>

<body>

    <div class="container" id="app">

        <div id="counter-event-example">
            <div >
                <button-counter v-on:increment1="incrementTotal1"></button-counter>
                <button-counter v-on:increment2="incrementTotal2"></button-counter>
            </div>
            <p>{{ total }}</p>


        </div>





    </div>



    <script src="http://localhost:8180//git-my/vue-ladder/src/lib/jquery.js"></script>
    <script src="http://localhost:8180//git-my/vue-ladder/src/lib/sea-all.js"></script>
    <script src="http://localhost:8180//git-my/vue-ladder/src/lib/seajs-style.js"></script>
    <script src="http://localhost:8180//git-my/vue-ladder/src/lib/seajs-debug.js"></script>

    <script src="http://localhost:8180//git-my/vue-ladder/src/lib/vue.js"></script>
    <script src="http://localhost:8180//git-my/vue-ladder/src/lib/vue-router.js"></script>

    <script src="http://localhost:8180//git-my/vue-ladder/src/lib/lodash.js"></script>

    <script src="http://localhost:8180//git-my/vue-ladder/src/page/boot.js"></script>

    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" />

    <script src="https://cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>

    <script>
        Vue.component('button-counter', {
            template: '<button v-on:click="increment">{{ counter }}</button>',
            data: function () {
                return {
                    counter: 0
                }
            },
            methods: {
                increment: function () {
                    this.counter += 1;
                    this.$emit('increment1', "这个位子是可以加参数的");//触发自定义increment1的函数。此处的increment1函数就是 incrementTotal1函数。
                    //                this.$emit('increment2');  //此时不会触发自定义increment2的函数。

                }
            }
        });
        new Vue({
            el: '#counter-event-example',
            data: {
                total: 0
            },
            methods: {
                incrementTotal1: function (e) {
                    this.total += 1;
                    console.log(e);
                },
                incrementTotal2: function () {
                    this.total += 1;
                }
            }
        })











    </script>



</body>

</html>